package gold.digger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC667 {
    public long startExecuteTime = System.currentTimeMillis();

    class Solution {
        public int[] constructArray(int n, int k) {
            int[] ans = new int[n];
            int bigSide = n, smallSide = 1;

            for (int i = 0; i < n - k; i++) {
                ans[i] = smallSide++;
            }

            boolean flag = true;
            for (int i = n - k; i < n; i++) {
                if (flag) ans[i] = bigSide--;
                else ans[i] = smallSide++;
                flag = !flag;
            }
            return ans;
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(Arrays.toString(solution.constructArray(8, 2)));
    }

    public static void main(String[] args) throws Exception {
        LC667 an = new LC667();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
